

<!DOCTYPE html>
<html lang="zh-CN" data-default-color-scheme=auto>



<head>
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="/blog/img/fluid.png">
  <link rel="icon" href="/blog/images/base.png">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
  <meta name="theme-color" content="#2f4154">
  <meta name="author" content="Airfe">
  <meta name="keywords" content="">
  
    <meta name="description" content="本文将介绍一些CSS3的新特性。">
<meta property="og:type" content="article">
<meta property="og:title" content="CSS3特性">
<meta property="og:url" content="https://airfe.gitee.io/blog/2023/04/19/CSS3%E7%89%B9%E6%80%A7/index.html">
<meta property="og:site_name" content="Airfe的博客">
<meta property="og:description" content="本文将介绍一些CSS3的新特性。">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://markdown-1307246189.cos.ap-chongqing.myqcloud.com/pageImage/CSS3%E7%89%B9%E6%80%A7.jpg">
<meta property="article:published_time" content="2023-04-19T00:00:00.000Z">
<meta property="article:modified_time" content="2024-02-26T12:19:49.955Z">
<meta property="article:author" content="Airfe">
<meta property="article:tag" content="css">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="https://markdown-1307246189.cos.ap-chongqing.myqcloud.com/pageImage/CSS3%E7%89%B9%E6%80%A7.jpg">
  
  
  
    <meta name="referrer" content="no-referrer" />
  
  <title>CSS3特性 - Airfe的博客</title>

  <link  rel="stylesheet" href="https://lib.baomitu.com/twitter-bootstrap/4.6.1/css/bootstrap.min.css" />



  <link  rel="stylesheet" href="https://lib.baomitu.com/github-markdown-css/4.0.0/github-markdown.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/hint.css/2.7.0/hint.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.css" />



<!-- 主题依赖的图标库，不要自行修改 -->
<!-- Do not modify the link that theme dependent icons -->

<link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_hj8rtnfg7um.css">



<link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_lbnruvf0jn.css">


<link  rel="stylesheet" href="/blog/css/main.css" />


  <link id="highlight-css" rel="stylesheet" href="/blog/css/highlight.css" />
  
    <link id="highlight-css-dark" rel="stylesheet" href="/blog/css/highlight-dark.css" />
  




  <script id="fluid-configs">
    var Fluid = window.Fluid || {};
    Fluid.ctx = Object.assign({}, Fluid.ctx)
    var CONFIG = {"hostname":"airfe.gitee.io","root":"/blog/","version":"1.9.4","typing":{"enable":true,"typeSpeed":70,"cursorChar":"_","loop":false,"scope":[]},"anchorjs":{"enable":true,"element":"h1,h2,h3,h4,h5,h6","placement":"left","visible":"hover","icon":""},"progressbar":{"enable":true,"height_px":3,"color":"#29d","options":{"showSpinner":false,"trickleSpeed":100}},"code_language":{"enable":true,"default":"TEXT"},"copy_btn":true,"image_caption":{"enable":true},"image_zoom":{"enable":true,"img_url_replace":["",""]},"toc":{"enable":true,"placement":"right","headingSelector":"h1,h2,h3,h4,h5,h6","collapseDepth":0},"lazyload":{"enable":true,"loading_img":"/img/loading.gif","onlypost":false,"offset_factor":2},"web_analytics":{"enable":true,"follow_dnt":true,"baidu":"699a5d71ac7179b23874a59b0666a6f6","google":null,"gtag":null,"tencent":{"sid":null,"cid":null},"woyaola":null,"cnzz":null,"leancloud":{"app_id":"RW68dMkEpeIOJJiBr1lPkhOS-gzGzoHsz","app_key":"P5fzMTGSJIoTaGvmgzsUHeNZ","server_url":"https://rw68dmke.lc-cn-n1-shared.com","path":"window.location.pathname","ignore_local":false}},"search_path":"/blog/local-search.xml"};

    if (CONFIG.web_analytics.follow_dnt) {
      var dntVal = navigator.doNotTrack || window.doNotTrack || navigator.msDoNotTrack;
      Fluid.ctx.dnt = dntVal && (dntVal.startsWith('1') || dntVal.startsWith('yes') || dntVal.startsWith('on'));
    }
  </script>
  <script  src="/blog/js/utils.js" ></script>
  <script  src="/blog/js/color-schema.js" ></script>
  

  
    <!-- Baidu Analytics -->
    <script async>
      if (!Fluid.ctx.dnt) {
        var _hmt = _hmt || [];
        (function() {
          var hm = document.createElement("script");
          hm.src = "https://hm.baidu.com/hm.js?699a5d71ac7179b23874a59b0666a6f6";
          var s = document.getElementsByTagName("script")[0];
          s.parentNode.insertBefore(hm, s);
        })();
      }
    </script>
  

  

  

  

  

  

  
    
  



  
<meta name="generator" content="Hexo 6.3.0"></head>


<body>
  

  <header>
    

<div class="header-inner" style="height: 70vh;">
  <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand" href="/blog/">
      <strong>Airfe</strong>
    </a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/blog/">
                <i class="iconfont icon-home-fill"></i>
                <span>首页</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/blog/archives/">
                <i class="iconfont icon-archive-fill"></i>
                <span>归档</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/blog/categories/">
                <i class="iconfont icon-category-fill"></i>
                <span>分类</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/blog/tags/">
                <i class="iconfont icon-tags-fill"></i>
                <span>标签</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/blog/about/">
                <i class="iconfont icon-user-fill"></i>
                <span>关于</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/blog/links/">
                <i class="iconfont icon-link-fill"></i>
                <span>友链</span>
              </a>
            </li>
          
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" target="_self" href="javascript:;" data-toggle="modal" data-target="#modalSearch" aria-label="Search">
              <i class="iconfont icon-search"></i>
            </a>
          </li>
          
        
        
          <li class="nav-item" id="color-toggle-btn">
            <a class="nav-link" target="_self" href="javascript:;" aria-label="Color Toggle">
              <i class="iconfont icon-dark" id="color-toggle-icon"></i>
            </a>
          </li>
        
      </ul>
    </div>
  </div>
</nav>

  

<div id="banner" class="banner" parallax=true
     style="background: url('/blog/images/bg.jpg') no-repeat center center; background-size: cover;">
  <div class="full-bg-img">
    <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
      <div class="banner-text text-center fade-in-up">
        <div class="h2">
          
            <span id="subtitle" data-typed-text="CSS3特性"></span>
          
        </div>

        
          
  <div class="mt-3">
    
    
      <span class="post-meta">
        <i class="iconfont icon-date-fill" aria-hidden="true"></i>
        <time datetime="2023-04-19 08:00" pubdate>
          2023年04月19日
        </time>
      </span>
    
  </div>

  <div class="mt-1">
    
      <span class="post-meta mr-2">
        <i class="iconfont icon-chart"></i>
        
          13k 字
        
      </span>
    

    
      <span class="post-meta mr-2">
        <i class="iconfont icon-clock-fill"></i>
        
        
        
          110 分钟
        
      </span>
    

    
    
  </div>


        
      </div>

      
    </div>
  </div>
</div>

</div>

  </header>

  <main>
    
      

<div class="container-fluid nopadding-x">
  <div class="row nomargin-x">
    <div class="side-col d-none d-lg-block col-lg-2">
      

    </div>

    <div class="col-lg-8 nopadding-x-md">
      <div class="container nopadding-x-md" id="board-ctn">
        <div id="board">
          <article class="post-content mx-auto">
            <!-- SEO header -->
            <h1 style="display: none">CSS3特性</h1>
            
            
              <div class="markdown-body">
                
                <h1 id="CSS3特性"><a href="#CSS3特性" class="headerlink" title="CSS3特性"></a>CSS3特性</h1><h2 id="⭐️-响应式布局"><a href="#⭐️-响应式布局" class="headerlink" title="⭐️ 响应式布局"></a>⭐️ 响应式布局</h2><h3 id="媒体查询"><a href="#媒体查询" class="headerlink" title="媒体查询"></a>媒体查询</h3><ul>
<li><p>媒体类型</p>
<p>示例</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><code class="hljs css"><span class="hljs-keyword">@media</span> print &#123;<br>    <span class="hljs-selector-tag">h1</span>&#123;<br>        <span class="hljs-attribute">background</span>: transparent;<br>    &#125;<br>&#125;<br></code></pre></td></tr></table></figure>

<table>
<thead>
<tr>
<th>值</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>all</td>
<td>检测所有设备。</td>
</tr>
<tr>
<td>screen</td>
<td>检测电子屏幕，包括:电脑屏幕、平板屏幕、手机屏幕等。</td>
</tr>
<tr>
<td>print</td>
<td>检测打印机。</td>
</tr>
</tbody></table>
<p>完整列表参考：<a target="_blank" rel="noopener" href="http://developer.mozilla.org/zh-CN/docs/Web/CSS/@media">http://developer.mozilla.org/zh-CN/docs/Web/CSS/@media</a></p>
</li>
<li><p>媒体特性</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br></pre></td><td class="code"><pre><code class="hljs css"><span class="hljs-comment">/* 检测到当前视口的宽度为800px时，应用如下样式 */</span><br><span class="hljs-keyword">@media</span> (<span class="hljs-attribute">width</span>:<span class="hljs-number">800px</span>) &#123;<br>    <span class="hljs-selector-tag">h1</span> &#123;<br>        <span class="hljs-attribute">background-color</span>: green;<br>    &#125;<br>&#125;<br><span class="hljs-comment">/* 检测到当前视口的宽度小于等于700px时，应用如下样式 */</span><br><span class="hljs-keyword">@media</span> (<span class="hljs-attribute">max-width</span>:<span class="hljs-number">700px</span>) &#123;<br>    <span class="hljs-selector-tag">h1</span> &#123;<br>        <span class="hljs-attribute">background-color</span>: orange;<br>    &#125;<br>&#125;<br><br><span class="hljs-comment">/* 检测到当前视口的宽度大于等于900px时，应用如下样式 */</span><br><span class="hljs-keyword">@media</span> (<span class="hljs-attribute">max-width</span>:<span class="hljs-number">700px</span>) &#123;<br>    <span class="hljs-selector-tag">h1</span> &#123;<br>        <span class="hljs-attribute">background-color</span>: deepskyblue;<br>    &#125;<br>&#125;<br><br><span class="hljs-comment">/* 检测到屏幕的宽度等于1536时，应用如下样式 */</span><br><span class="hljs-keyword">@media</span> (<span class="hljs-attribute">device-width</span>:<span class="hljs-number">1536px</span>) &#123;<br>    <span class="hljs-selector-tag">h1</span> &#123;<br>       <span class="hljs-attribute">color</span>: white;<br>    &#125;<br>&#125;<br></code></pre></td></tr></table></figure>

<p>完整列表参考：<a target="_blank" rel="noopener" href="http://developer.mozilla.org/zh-CN/docs/Web/CSS/@media">http://developer.mozilla.org/zh-CN/docs/Web/CSS/@media</a></p>
</li>
<li><p>运算符</p>
<p>示例</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><code class="hljs css"><span class="hljs-comment">/* 且运算符 */</span><br><span class="hljs-keyword">@media</span> (<span class="hljs-attribute">min-width</span>:<span class="hljs-number">700px</span>) <span class="hljs-keyword">and</span> (<span class="hljs-attribute">max-width</span>:<span class="hljs-number">800px</span>) &#123;<br>    <span class="hljs-selector-tag">h1</span>&#123;<br>         <span class="hljs-attribute">background-color</span>: orange;<br>    &#125;<br>&#125;  <br></code></pre></td></tr></table></figure>

<table>
<thead>
<tr>
<th>值</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>and</td>
<td>并且</td>
</tr>
<tr>
<td>,或or</td>
<td>或</td>
</tr>
<tr>
<td>not</td>
<td>否定</td>
</tr>
<tr>
<td>only</td>
<td>肯定</td>
</tr>
</tbody></table>
</li>
<li><p>常用阈值</p>
<p>在实际开发中，会将屏幕划分成几个区间，例如 超小屏幕-768px-中等屏幕-992px-大屏幕-1200px-超大屏幕</p>
<p>开发中常用</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs css">&lt;link rel=&quot; stylesheet&quot; media=&quot;具体的媒体查询” href= &quot;./css/huge<span class="hljs-selector-class">.css</span>&quot;&gt;<br>// 大屏幕的样式单独写在huge<span class="hljs-selector-class">.css</span>中即可<br></code></pre></td></tr></table></figure></li>
</ul>
<h3 id="Flex-布局"><a href="#Flex-布局" class="headerlink" title="Flex 布局"></a>Flex 布局</h3><p>由于<code>Flex</code> 布局比较重要且常用，作者会单独开一篇文章。</p>
<h3 id="Grid-布局"><a href="#Grid-布局" class="headerlink" title="Grid 布局"></a>Grid 布局</h3><p><code>CSS3</code>引入的一种新的布局模型——<code>Grids</code>网格布局，目前暂未推广使用，使用频率较低，此处不作介绍。</p>
<h3 id="瀑布流"><a href="#瀑布流" class="headerlink" title="瀑布流"></a>瀑布流</h3><p><code>CSS3</code> 的<code>Multi-columns</code>是最早尝试使用纯CSS方法解决瀑布流布局的方法。</p>
<p>通过Multi-columns相关的属性<code>column-count</code>、<code>column-gap</code>配合<code>break-inside</code>可以实现瀑布流布局。</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br></pre></td><td class="code"><pre><code class="hljs html"><span class="hljs-tag">&lt;<span class="hljs-name">style</span>&gt;</span><span class="language-css"></span><br><span class="language-css">    <span class="hljs-selector-class">.masonry</span> &#123;</span><br><span class="language-css">        <span class="hljs-attribute">column-count</span>: <span class="hljs-number">2</span>;</span><br><span class="language-css">        <span class="hljs-attribute">column-gap</span>: <span class="hljs-number">0</span>;</span><br><span class="language-css">        <span class="hljs-attribute">width</span>: <span class="hljs-number">400px</span>;</span><br><span class="language-css">    &#125;</span><br><span class="language-css">    <span class="hljs-selector-class">.item</span> &#123;</span><br><span class="language-css">        <span class="hljs-comment">/* 定义页面、列或区域发生中断时候的元素该如何表现。如果没有中断，则忽略该属性。*/</span></span><br><span class="language-css">        <span class="hljs-attribute">break-inside</span>: avoid; </span><br><span class="language-css">        <span class="hljs-attribute">width</span>: <span class="hljs-number">200px</span>;</span><br><span class="language-css">        <span class="hljs-attribute">height</span>: <span class="hljs-number">200px</span>;</span><br><span class="language-css">    &#125;</span><br><span class="language-css"></span><span class="hljs-tag">&lt;/<span class="hljs-name">style</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;masonry&quot;</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;item&quot;</span> <span class="hljs-attr">style</span>=<span class="hljs-string">&quot;background-color: pink&quot;</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;item__content&quot;</span>&gt;</span><br>        <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span><br>    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;item&quot;</span> <span class="hljs-attr">style</span>=<span class="hljs-string">&quot;background-color: green&quot;</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;item__content&quot;</span>&gt;</span><br>        <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span><br>    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;item&quot;</span> <span class="hljs-attr">style</span>=<span class="hljs-string">&quot;background-color: red&quot;</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;item__content&quot;</span>&gt;</span><br>        <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span><br>    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span><br>    <span class="hljs-comment">&lt;!-- more items --&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span><br></code></pre></td></tr></table></figure>

<p>更优的解决方案还有Flex中使用列容器，使用Flexbox布局，对于<code>.item</code>可以不再使用<code>break-inside:avoid</code>。一般使用这个方法。</p>
<p>其他解决方案还有Grid布局，不过缺点是对于堆栈（列表项目）高度不能友好的控制。</p>
<h2 id="新增盒子属性"><a href="#新增盒子属性" class="headerlink" title="新增盒子属性"></a>新增盒子属性</h2><h3 id="box-sizing"><a href="#box-sizing" class="headerlink" title="box- sizing"></a>box- sizing</h3><p><code>CSS3</code>中可以通过<code>box- sizing</code>来指定盒模型，有2个值：即可指定为<code>content- box</code>、<code>border-box</code>，这样我们计算盒子大小的方式就发生了改变。</p>
<ul>
<li>box-sizing: content-box   width和height设置的是盒子内容区的大小  盒子总大小 &#x3D; width + padding + border ( 默认模式)</li>
<li><strong>box-sizing: border-box</strong>    width和height设置的是盒子总大小</li>
</ul>
<h3 id="resize改变大小"><a href="#resize改变大小" class="headerlink" title="resize改变大小"></a>resize改变大小</h3><figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><code class="hljs css"><span class="hljs-selector-class">.box</span>&#123;<br>    <span class="hljs-attribute">width</span>:<span class="hljs-number">400px</span>;<br>    <span class="hljs-attribute">height</span>:<span class="hljs-number">400px</span>;<br>    <span class="hljs-attribute">background-color</span>:orange;<br>    // 如果想实现<span class="hljs-attribute">resize</span>必须添加<span class="hljs-attribute">overflow</span>属性<br>    <span class="hljs-attribute">overflow</span>:hidden; <br>    // 可以调节水平 || 垂直 || 两个方向的盒子大小,<span class="hljs-attribute">none</span>是默认的不允许用户调整元素大小<br>    <span class="hljs-attribute">resize</span>:horizontal || vertical || both || none<br>&#125;<br></code></pre></td></tr></table></figure>

<blockquote>
<p>overflow的值为hidden即超出隐藏，为auto即超出使用滚动条 ，为scroll时一直有滚动条。</p>
</blockquote>
<h3 id="阴影"><a href="#阴影" class="headerlink" title="阴影"></a>阴影</h3><p><strong>盒子阴影box-shadow</strong></p>
<table>
<thead>
<tr>
<th>值</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>h-shadow</td>
<td>必填。水平阴影的位置。允许负值。</td>
</tr>
<tr>
<td>v-shadow</td>
<td>必填。垂直阴影的位置。允许负值。</td>
</tr>
<tr>
<td>blur</td>
<td>可选。模糊距离。</td>
</tr>
<tr>
<td>spread</td>
<td>可选。阴影的尺寸。</td>
</tr>
<tr>
<td>color</td>
<td>可选。阴影的颜色。</td>
</tr>
<tr>
<td>inset</td>
<td>可选。将外部阴影(outset) 改为内部阴影。</td>
</tr>
</tbody></table>
<p>默认<code>box-shadow:none</code>表示没有阴影。</p>
<p>示例</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs css"><span class="hljs-attribute">box-shadow</span>: <span class="hljs-number">10px</span> <span class="hljs-number">10px</span> <span class="hljs-number">10px</span> <span class="hljs-number">10px</span> <span class="hljs-built_in">rgba</span>(<span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, .<span class="hljs-number">3</span>)<br></code></pre></td></tr></table></figure>

<p><strong>文字阴影text-shadow</strong></p>
<table>
<thead>
<tr>
<th>值</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>h-shadow</td>
<td>必填。水平阴影的位置。允许负值。</td>
</tr>
<tr>
<td>v-shadow</td>
<td>必填。垂直阴影的位置。允许负值。</td>
</tr>
<tr>
<td>blur</td>
<td>可选。模糊距离。</td>
</tr>
<tr>
<td>color</td>
<td>可选。阴影的颜色。</td>
</tr>
</tbody></table>
<p>示例</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs css"><span class="hljs-attribute">text-shadow</span>: <span class="hljs-number">5px</span> <span class="hljs-number">5px</span> <span class="hljs-number">6px</span> <span class="hljs-built_in">rgba</span>(<span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, .<span class="hljs-number">3</span>)<br></code></pre></td></tr></table></figure>

<h3 id="opacity透明度"><a href="#opacity透明度" class="headerlink" title="opacity透明度"></a>opacity透明度</h3><p>opacity属性能为整个元素添和透明效果，<strong>值是0到1之间的小数，0是完全透明，1 表示完全不透明</strong>。</p>
<blockquote>
<p>opacity与rgba的区别?</p>
<p>opacity是一个属性，设置的是整个元素(包括元素里的内容)的不透明度。rgba的透明度，仅调整颜色的透明度。</p>
</blockquote>
<h2 id="新增选择器"><a href="#新增选择器" class="headerlink" title="新增选择器"></a>新增选择器</h2><h3 id="属性选择器"><a href="#属性选择器" class="headerlink" title="属性选择器"></a>属性选择器</h3><table>
<thead>
<tr>
<th>选择符</th>
<th>简介</th>
</tr>
</thead>
<tbody><tr>
<td>E[att]</td>
<td>选择具有att属性的E元素</td>
</tr>
<tr>
<td>E[att&#x3D;”val”]</td>
<td>选择具有att属性且属性值等于val的E元素</td>
</tr>
<tr>
<td>E[att^&#x3D;”val”]</td>
<td>匹配具有att 属性且值以val开头的E元素</td>
</tr>
<tr>
<td>E[att$&#x3D;”val”]</td>
<td>匹配具有att属性且值以val结尾的E元素</td>
</tr>
<tr>
<td>E[att*&#x3D;”val”]</td>
<td>匹配具有att属性且值中含有val的E元素</td>
</tr>
</tbody></table>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><code class="hljs html"><span class="hljs-tag">&lt;<span class="hljs-name">style</span>&gt;</span><span class="language-css"></span><br><span class="language-css">    <span class="hljs-comment">/*只选择type=text 文本框的input 选取出来*/</span></span><br><span class="language-css">    <span class="hljs-selector-tag">input</span><span class="hljs-selector-attr">[type=text]</span>&#123;</span><br><span class="language-css">        <span class="hljs-attribute">color</span>:pink;</span><br><span class="language-css">    &#125;</span><br><span class="language-css">    <span class="hljs-comment">/*选择首先是div然后具有class属性并且属性值必须是icon开头的这些元素*/</span></span><br><span class="language-css">    <span class="hljs-selector-tag">div</span><span class="hljs-selector-attr">[class^=icon]</span>&#123;</span><br><span class="language-css">        <span class="hljs-attribute">color</span>:red;</span><br><span class="language-css">    &#125;</span><br><span class="language-css"></span><br><span class="language-css"></span><br><span class="language-css"></span><span class="hljs-tag">&lt;/<span class="hljs-name">style</span>&gt;</span><br><br><span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">&quot;text&quot;</span> <span class="hljs-attr">name</span>=<span class="hljs-string">&quot;&quot;</span>  <span class="hljs-attr">id</span>=<span class="hljs-string">&quot;&quot;</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">&quot;password&quot;</span> <span class="hljs-attr">name</span>=<span class="hljs-string">&quot;&quot;</span>  <span class="hljs-attr">id</span>=<span class="hljs-string">&quot;&quot;</span>&gt;</span><br><br><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;icon1&quot;</span> &gt;</span>小图标1<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;icon2&quot;</span> &gt;</span>小图标2<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;icon3&quot;</span> &gt;</span>小图标3<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span><br></code></pre></td></tr></table></figure>

<h3 id="结构伪类选择器"><a href="#结构伪类选择器" class="headerlink" title="结构伪类选择器"></a>结构伪类选择器</h3><table>
<thead>
<tr>
<th>选择器</th>
<th>简介</th>
</tr>
</thead>
<tbody><tr>
<td>E:first-child</td>
<td>匹配父元素中的第一个子元素 E</td>
</tr>
<tr>
<td>E:last-child</td>
<td>匹配父元素中最后一一个E元素</td>
</tr>
<tr>
<td>E:nth-child(n)</td>
<td>匹配父元素中的第n个子元素E</td>
</tr>
<tr>
<td>E:first-of-type</td>
<td>指定类型E的第一个</td>
</tr>
<tr>
<td>E:last-of-type</td>
<td>指定类型E的最后一个</td>
</tr>
<tr>
<td>E:nth-of-type(n)</td>
<td>指定类型E的第n个</td>
</tr>
</tbody></table>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><code class="hljs css"><span class="hljs-comment">/* 2.选择uL里面的最后一个孩子小Li */</span><br><span class="hljs-selector-tag">ul</span> <span class="hljs-selector-tag">li</span> <span class="hljs-selector-pseudo">:last-child</span> &#123;<br>    <span class="hljs-attribute">background-color</span>: pink;<br>&#125;<br><span class="hljs-comment">/* 3.选择uL里面的第2个孩子小Li */</span><br><span class="hljs-selector-tag">ul</span> <span class="hljs-selector-tag">li</span> <span class="hljs-selector-pseudo">:nth-child</span>(<span class="hljs-number">2</span>) &#123;<br>    <span class="hljs-attribute">background-color</span>:D skyblue;<br>&#125;<br></code></pre></td></tr></table></figure>

<p><code>nth-child (n)</code>选择某个父元素的一个或多个特定的子元素，n可以是数字，关键字和公式</p>
<ul>
<li>n如果是数字，就是选择第n个子元素，里面数字从1开始…</li>
<li>n可以是关键字: even偶数, odd奇数</li>
<li>n可以是公式:常见的公式如下(如果n是公式,则从0开始计算,但是第0个元素或者超出了元素的个数会被忽略)</li>
</ul>
<h3 id="伪元素选择器"><a href="#伪元素选择器" class="headerlink" title="伪元素选择器"></a>伪元素选择器</h3><p>使用场景：伪元素选择器可以帮助我们利用CSS创建新标签元素，而不需要HTML标签，从而简化HTML结构。</p>
<table>
<thead>
<tr>
<th>选择器</th>
<th>简介</th>
</tr>
</thead>
<tbody><tr>
<td>::before</td>
<td>在元素<strong>内部</strong>的前面插入内容</td>
</tr>
<tr>
<td>::after</td>
<td>在元素<strong>内部</strong>的后面插入内容</td>
</tr>
</tbody></table>
<ul>
<li>语法：element::before{} </li>
<li>before和after必须有<strong>content属性</strong></li>
<li>由于创建的伪元素是<strong>行内元素</strong>，设置宽高不起作用，要转化为block或者inline-block，或者带浮动、定位。<strong>更多的与定位搭配使用</strong>。</li>
<li>伪元素选择器和标签选择器一样，权重为1。</li>
</ul>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><code class="hljs js"><span class="hljs-attr">div</span>::before &#123;  <span class="hljs-comment">// 权重是2</span><br>    <span class="hljs-comment">/*这个content是必须要 写的*/</span><br>    <span class="hljs-attr">display</span>: inline-block;<br>    <span class="hljs-attr">content</span>: <span class="hljs-string">&#x27;我&#x27;</span>;<br>    <span class="hljs-attr">width</span>: 30px;<br>    <span class="hljs-attr">height</span>: 40px;<br>    background-<span class="hljs-attr">color</span>: purple;<br>&#125;<br><span class="hljs-attr">div</span>: :after &#123;<br>    <span class="hljs-attr">content</span>: <span class="hljs-string">&#x27;小猪佩奇 &#x27;</span>;<br>&#125;<br><br>&lt;div&gt;是&lt;div/&gt;<br></code></pre></td></tr></table></figure>

<h2 id="新增样式"><a href="#新增样式" class="headerlink" title="新增样式"></a>新增样式</h2><h3 id="渐变"><a href="#渐变" class="headerlink" title="渐变"></a>渐变</h3><ul>
<li><p>线性渐变</p>
<p>多个颜色之间的渐变，默认是<strong>从上到下</strong>渐变。</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs css"><span class="hljs-attribute">background-image</span>: <span class="hljs-built_in">linear-gradient</span>( red, yellow, green);<br></code></pre></td></tr></table></figure>

<p>使用<strong>关键词设置线性渐变的方向</strong>。</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs css"><span class="hljs-attribute">background</span>- image: <span class="hljs-built_in">linear-gradient</span>(to top, red, yellow, green);<br><span class="hljs-attribute">background</span>- image: <span class="hljs-built_in">linear-gradient</span>(to right top, red, yellow, green);<br></code></pre></td></tr></table></figure>

<p>使用<strong>角度设置线性渐变的方向</strong>。</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs css"><span class="hljs-attribute">background-image</span>: <span class="hljs-built_in">linear-gradient</span>(<span class="hljs-number">30deg</span>, red, yellow, green);<br></code></pre></td></tr></table></figure>

<p>调整开始<strong>渐变的位置</strong></p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs css"><span class="hljs-attribute">background-image</span>: <span class="hljs-built_in">linear-gradient</span>(red <span class="hljs-number">50px</span>, yellow <span class="hljs-number">100px</span> green <span class="hljs-number">150px</span>);<br></code></pre></td></tr></table></figure>
</li>
<li><p>径向渐变</p>
<p>多个颜色之间的渐变，默认从圆心向外发散。</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs css"><span class="hljs-attribute">background-image</span>: <span class="hljs-built_in">radial-gradient</span>(red,yellow,green);<br></code></pre></td></tr></table></figure>

<p>使用关键词调整渐变圆的圆心位置。</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs css"><span class="hljs-attribute">background-image</span>: <span class="hljs-built_in">radial-gradient</span>(at right top, red, yellow, green);<br></code></pre></td></tr></table></figure>

<p>使用像索值调整渐交圆的圆心位置。</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs css"><span class="hljs-attribute">background-image</span>: <span class="hljs-built_in">radial-gradient</span>(at <span class="hljs-number">100px</span> <span class="hljs-number">50px</span>, red, yellow, green);<br></code></pre></td></tr></table></figure>

<p>调整渐变形状为正圆。</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs css"><span class="hljs-attribute">background-image</span>: <span class="hljs-built_in">radial-gradient</span>(circle, red, yellow, green);<br></code></pre></td></tr></table></figure>

<p>调整形状的半径。</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs css"><span class="hljs-attribute">background-image</span>: <span class="hljs-built_in">radial-gradient</span>(<span class="hljs-number">100px</span>, red, yellow, green);<br><span class="hljs-attribute">background-image</span>: <span class="hljs-built_in">radial-gradient</span>(<span class="hljs-number">50px</span> <span class="hljs-number">100px</span>, red, yellow, green); <br></code></pre></td></tr></table></figure>

<p>调整开始渐变的位置。</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs css"><span class="hljs-attribute">background-image</span>: <span class="hljs-built_in">radial-gradient</span>(red <span class="hljs-number">50px</span>, yellow <span class="hljs-number">108px</span>, green <span class="hljs-number">158px</span>);<br></code></pre></td></tr></table></figure>
</li>
<li><p>重复渐变</p>
<p>在没有发生渐变的区域（纯色区域），重新开始渐变，就是重复渐变</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><code class="hljs css"><span class="hljs-selector-class">.box1</span> &#123;<br>    <span class="hljs-attribute">background-image</span>: <span class="hljs-built_in">repeating-linear-gradient</span>(red <span class="hljs-number">50px</span>, yellow <span class="hljs-number">100px</span>, green <span class="hljs-number">150px</span>);<br>&#125;<br><span class="hljs-selector-class">.box2</span> &#123;<br>    <span class="hljs-attribute">background-image</span>: <span class="hljs-built_in">repeating-radial-gradient</span>(red <span class="hljs-number">50px</span>, yellow <span class="hljs-number">100px</span>, green <span class="hljs-number">150px</span>);<br>&#125;  <br></code></pre></td></tr></table></figure></li>
</ul>
<h3 id="边框"><a href="#边框" class="headerlink" title="边框"></a>边框</h3><ul>
<li><p>圆角</p>
<p>使用<code>border-radius</code>可以将盒子变为圆角</p>
<p>同时设置四个角的圆角示例</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs css"><span class="hljs-attribute">border-radius</span>:<span class="hljs-number">10px</span>;<br></code></pre></td></tr></table></figure>
</li>
<li><p>外轮廓</p>
<p>可以理解为盒子发出的“光”，不占位置，不参数盒子大小计算。</p>
<ul>
<li><p><code>outline-width</code>：外轮廓的宽度</p>
</li>
<li><p><code>outline-color</code>：外轮廓的颜色</p>
</li>
<li><p><code>outline-style</code>：外轮廓的风格</p>
<ul>
<li><code>none</code>：无轮廓</li>
<li><code>dotted</code>：点状轮廓</li>
<li><code>dashed</code>：虚线轮廓</li>
<li><code>solid</code>：实线轮廓</li>
<li><code>double</code>：双线轮廓</li>
</ul>
</li>
<li><p><code>outline-offset</code>：设置外轮廓与边框的距离，正负值都可以设置。</p>
<blockquote>
<p>outline-offset不是outline的子属性，是一个独立的属性。</p>
</blockquote>
</li>
<li><p><code>outline</code>：复合属性</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs css"><span class="hljs-attribute">outline</span>:<span class="hljs-number">50px</span> solid blue;<br></code></pre></td></tr></table></figure></li>
</ul>
</li>
</ul>
<h3 id="文本"><a href="#文本" class="headerlink" title="文本"></a>文本</h3><h4 id="文本属性"><a href="#文本属性" class="headerlink" title="文本属性"></a>文本属性</h4><ul>
<li><p>文本阴影<code>text-shadow</code>在前面谈新增盒子属性阴影时一并说了。</p>
</li>
<li><p>文本换行<code>white-space</code></p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs css"><span class="hljs-attribute">white-space</span>:normal | pre | pre-wrap | pre-line | nowrap<br></code></pre></td></tr></table></figure>

<ul>
<li><code>normal</code>：文本超出边界自动换行，文本中的换行被测览器识别为一个空格。(默认值)</li>
<li><code>pre</code>：原样输出，与<code>pre</code>标签的效果相同。</li>
<li><code>pre-wrap </code>：在<code>pre</code>果的基础上，超出元素边界自动换行，且只识别文本中的换行，空格会忽略。</li>
<li><code>nowrap</code>：强制不换行。</li>
</ul>
</li>
<li><p>文本溢出<code>text-overflow</code></p>
<p>常用值</p>
<ul>
<li><code>clip</code>：当内联内容溢出时，将溢出部分裁剪掉。</li>
<li><code>ellipsis</code>：当内联内容溢出块容器时，将溢出部分替换为…。</li>
</ul>
<blockquote>
<p>要使得<code>text-overflow</code>属性生效，块容器必须显式定义overflow为非visible值，<code>white-space</code>为<code>nowrap</code>值。</p>
</blockquote>
</li>
<li><p>文本修饰<code>text-decoration</code></p>
<p>CSS3将<code>text-decoration</code>升级成了一个复合属性。</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs css"><span class="hljs-attribute">text-decoration</span>: text-decoration-line || text-decoration-style || text-decoration-color<br></code></pre></td></tr></table></figure>
<ul>
<li><code>text-decoration-line</code> 设置文本装饰线的位置<ul>
<li><code>none</code>：指定文字无装饰（默认值）</li>
<li><code>underline</code>：指定文字的装饰是下划线</li>
<li><code>overline</code>：指定文字的装饰是上划线</li>
<li><code>line-through</code>：指定文字的装饰是贯穿线</li>
</ul>
</li>
<li><code>text-decoration-style</code> 文本装饰线条的形状<ul>
<li><code>solid</code>：实线（默认）</li>
<li><code>double</code>：双线</li>
<li><code>dotted</code>：点状线条</li>
<li><code>dashed</code>：虚线</li>
<li><code>wavy</code>：波浪线</li>
</ul>
</li>
<li><code>text-decoration-color</code>文本装饰线条的颜色</li>
</ul>
</li>
<li><p>文本描边<code>-webkit-text-stroke</code></p>
<p>文本描边属性仅<code>webkit</code>内核浏览器支持</p>
<ul>
<li><code>-webkit-text-stroke-width</code>：设置文字描边的宽度，写长度值。</li>
<li><code>-webkit-text-stroke-color</code>：设置文字描边的颜色，写颜色值。</li>
<li><code>-webkit-text-stroke</code>：复合属性,设置文字描边宽度和颜色。</li>
</ul>
</li>
</ul>
<h4 id="web字体"><a href="#web字体" class="headerlink" title="web字体"></a>web字体</h4><ul>
<li>相比图片更加清晰。</li>
<li>灵活性高，更方便改变大小、颜色、风格等。</li>
<li>兼容性好，IE 也能支持。</li>
</ul>
<p>参考阿中图标百网地址： <a target="_blank" rel="noopener" href="https://www.iconfont.cn/">https://www.iconfont.cn/</a></p>
<h3 id="滤镜filter"><a href="#滤镜filter" class="headerlink" title="滤镜filter"></a>滤镜filter</h3><p>filter CSS属性将模糊或颜色偏移等图形效果应用于元素。</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs css"><span class="hljs-comment">/* blur是一个函数小括号里面数值越大，图片越模糊注意数值要加px单位*/</span><br><span class="hljs-attribute">filter</span>: <span class="hljs-built_in">blur</span>(<span class="hljs-number">5px</span>);  <br></code></pre></td></tr></table></figure>

<h3 id="背景"><a href="#背景" class="headerlink" title="背景"></a>背景</h3><ul>
<li><p>background-origin</p>
<p>用于设置背景图的原点。默认原点是从padding的左上角开始的。</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs css"><span class="hljs-attribute">background-origin</span>:<span class="hljs-built_in">padding-box</span>(默认) | content-box | border-box<br></code></pre></td></tr></table></figure>
</li>
<li><p>background-clip</p>
<p>设置背景图的向外裁剪的区域。</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs css"><span class="hljs-attribute">background-origin</span>:<span class="hljs-built_in">border-box</span>(默认) | padding-box | content-box | text<br></code></pre></td></tr></table></figure>

<ul>
<li>border-box: 从border区域开始向外裁剪背景。- -默认值</li>
<li>padding- box:从padding区域开始向外裁剪背景。</li>
<li>content- box:从content区域开始向外裁剪背品。</li>
<li>text: 背景图只呈现在文字上。</li>
</ul>
</li>
</ul>
<blockquote>
<p>若值为text，那么backgroun-clip要加上-webkit-前缀。</p>
</blockquote>
<ul>
<li><p>background-size</p>
<p>语法</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs css"><span class="hljs-attribute">background-size</span>: length|percentage|cover|contain;<br></code></pre></td></tr></table></figure>

<ul>
<li>length：设置背景图片的高度与宽度。第一个值设置宽度，第二个值为高度。</li>
<li>percentage：将计算相对于背景定位区域的百分比。第一个值设置宽度，第二个值为高度。</li>
<li>cover：保持图像的横纵比将图像缩放成完全覆盖背景定位区域的最小大小。</li>
<li>contain：保持图像的横纵比将图像缩放成适应背景区域的最大大小。</li>
</ul>
</li>
<li><p>background-复合属性</p>
<p>语法</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs css"><span class="hljs-attribute">background</span>:背景颜色 背景图片地址 背景平铺 背景图像滚动 背景图片位置 原点位置 向外裁剪的区域<br></code></pre></td></tr></table></figure>

<p>顺序不要求一致，可自动识别</p>
<blockquote>
<p>origin和cltp的值如果-样，如果只写一一个值，则origin和clip都设置:如果设置了两个值，前面的是origin,后面的clip.</p>
</blockquote>
</li>
<li><p>多背景图</p>
<p>CSS3允许元素设置多个背景图片</p>
<p>示例</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><code class="hljs css"><span class="hljs-comment">/* 添加多个背景图 */</span> <br><span class="hljs-attribute">background</span>:<span class="hljs-built_in">url</span>(<span class="hljs-string">../images/bg-lt.png</span>) np-repeat,<br>           <span class="hljs-built_in">url</span>(<span class="hljs-string">../images/bg-rt.png</span>) np-repeat right top,<br>           <span class="hljs-built_in">url</span>(<span class="hljs-string">../images/bg-lb.png</span>) np-repeat left bottom,<br>           <span class="hljs-built_in">url</span>(<span class="hljs-string">../images/bg-rb.png</span>) np-repeat right bottom;<br></code></pre></td></tr></table></figure></li>
</ul>
<h2 id="新增长度单位"><a href="#新增长度单位" class="headerlink" title="新增长度单位"></a>新增长度单位</h2><p>CSS2的长度单位有px（像素单位）、%、em（相对于当前元素的字体尺寸），CSS3新增了rem（相对于根元素字体大小）、<strong>vw</strong>（相对于视窗宽度）、<strong>vh</strong>（相对</p>
<p>于视窗高度）、vmax、vmin长度单位。</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><code class="hljs css"><span class="hljs-selector-class">.box</span>&#123;<br>    <span class="hljs-attribute">width</span>: <span class="hljs-number">50vw</span>; <br>    <span class="hljs-attribute">height</span>: <span class="hljs-number">20vw</span>;<br>    <span class="hljs-attribute">background-color</span>: green;<br>    <span class="hljs-attribute">margin</span>: <span class="hljs-number">0</span> auto;<br>&#125;<br></code></pre></td></tr></table></figure>

<h3 id="计算宽度calc"><a href="#计算宽度calc" class="headerlink" title="计算宽度calc"></a>计算宽度calc</h3><p>此CSS函数让你在声明CSS属性值时执行一些计算。</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs html">width: calc(100% 80px);<br></code></pre></td></tr></table></figure>

<p>括号里面可以使用+ 、—、*、&#x2F; 来进行计算。</p>
<h2 id="过渡"><a href="#过渡" class="headerlink" title="过渡"></a>过渡</h2><p>过渡动画：是从一个状态渐渐的过渡到另外一个状态。</p>
<blockquote>
<p>过渡( transition)是CSS3中具有颠覆性的特征之一，我们可以在不使用 Flash 动画或JavaScript的情况下，控制元素属性发生变化时的过程效果。经常和<code>:hover</code></p>
<p>一起搭配使用。</p>
</blockquote>
<p>格式</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs css"><span class="hljs-attribute">transition</span>:要过渡的属性  花费时间  运动曲线  何时开始;<br></code></pre></td></tr></table></figure>

<ul>
<li>属性：想要变化的css属性，宽度高度背景颜色内外边距都可以。如果想要所有的属性都变化过渡，写一个<strong>all</strong> 就可以。</li>
<li>花费时间：单位是秒(必须写单位)比如0.5s</li>
<li>运动曲线：默认是ease：逐渐慢下来  linear：匀速    ease-in：加速   ease-out：减速   ease-in-out：先加速后减速</li>
<li>何时开始：单位是秒(必)可以设置延迟触发时间  默认是0s ( 可以省略)</li>
</ul>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><code class="hljs css"><span class="hljs-selector-tag">div</span>&#123;<br>    <span class="hljs-attribute">width</span>: <span class="hljs-number">200px</span>;<br>    <span class="hljs-attribute">height</span>: <span class="hljs-number">100px</span>;<br>    <span class="hljs-attribute">background-color</span>: pink;<br>    <span class="hljs-comment">/* transition:变化的属性  花费时间  运动曲线   何时开始 */</span><br>    <span class="hljs-attribute">transition</span>: width .<span class="hljs-number">5s</span>;<br>     <span class="hljs-comment">/* transition: width .5s,height .5s; */</span><br>&#125;<br><br><span class="hljs-selector-tag">div</span><span class="hljs-selector-pseudo">:hover</span>&#123;<br>    <span class="hljs-attribute">width</span>: <span class="hljs-number">400px</span>;<br>    // <span class="hljs-attribute">height</span>:<span class="hljs-number">200px</span>;<br>&#125;<br></code></pre></td></tr></table></figure>

<h2 id="动画"><a href="#动画" class="headerlink" title="动画"></a>动画</h2><p>动画( animation )可通过设置多个节点来精确控制一个或一组动画，常用来实现复杂的动画效果。</p>
<p>相比较过渡，动画可以实现更多变化，更多控制，比如连续<strong>自动播放</strong>等效果是过渡做不了的。</p>
<h3 id="基本使用"><a href="#基本使用" class="headerlink" title="基本使用"></a>基本使用</h3><ol>
<li><p>先定义动画</p>
<p>用Keyframes定义动画（类似定义类选择器）</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><code class="hljs css">// move是自定义的动画 <br><span class="hljs-keyword">@keyframs</span> move &#123;<br>    <span class="hljs-comment">/* 开始状态 */</span><br>    <span class="hljs-number">0%</span> &#123;<br>        <span class="hljs-attribute">transform</span>: <span class="hljs-built_in">translateX</span>(<span class="hljs-number">0px</span>); <br>    &#125;<br>    <span class="hljs-comment">/* 结束状态 */</span><br>    <span class="hljs-number">100%</span>&#123;<br>        <span class="hljs-attribute">transform</span>: <span class="hljs-built_in">translateX</span>(<span class="hljs-number">1000px</span>);<br>    &#125;<br>&#125;<br></code></pre></td></tr></table></figure>
</li>
<li><p>再使用（调用）动画</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><code class="hljs css">// 调用动画<br><span class="hljs-selector-tag">div</span>&#123;<br>    <span class="hljs-attribute">width</span>:<span class="hljs-number">200px</span>;<br>    <span class="hljs-attribute">height</span>:<span class="hljs-number">200px</span>;<br>    <span class="hljs-comment">/* 调用动画 */</span><br>    <span class="hljs-attribute">animation-name</span>:move;<br>    <span class="hljs-comment">/* 持续时间 */</span><br>    <span class="hljs-attribute">animation-duration</span>:<span class="hljs-number">2s</span>;<br>&#125;<br></code></pre></td></tr></table></figure></li>
</ol>
<h3 id="动画序列"><a href="#动画序列" class="headerlink" title="动画序列"></a>动画序列</h3><figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br></pre></td><td class="code"><pre><code class="hljs css">// 可以做多个状态的变化 里面的百分比是总时间的划分 <br><span class="hljs-keyword">@keyframs</span> move &#123;<br>    <span class="hljs-comment">/* 开始状态 */</span><br>    <span class="hljs-number">0%</span> &#123;<br>        <span class="hljs-attribute">transform</span>: <span class="hljs-built_in">translate</span>(<span class="hljs-number">0</span>,<span class="hljs-number">0</span>); <br>    &#125;<br>    <span class="hljs-number">25%</span> &#123;<br>        <span class="hljs-attribute">transform</span>: <span class="hljs-built_in">translate</span>(<span class="hljs-number">10000px</span>,<span class="hljs-number">0</span>); <br>    &#125;<br>    <span class="hljs-number">50%</span> &#123;<br>        <span class="hljs-attribute">transform</span>: <span class="hljs-built_in">translate</span>(<span class="hljs-number">1000px</span>,<span class="hljs-number">500px</span>); <br>    &#125;<br>    <span class="hljs-number">75%</span> &#123;<br>        <span class="hljs-attribute">transform</span>: <span class="hljs-built_in">translate</span>(<span class="hljs-number">0</span>,<span class="hljs-number">500px</span>); <br>    &#125;<br>    <span class="hljs-comment">/* 结束状态 */</span><br>    <span class="hljs-number">100%</span> &#123;<br>       <span class="hljs-attribute">transform</span>: <span class="hljs-built_in">translate</span>(<span class="hljs-number">0</span>,<span class="hljs-number">0</span>); <br>    &#125;<br>&#125;<br><br>// 调用动画<br><span class="hljs-selector-tag">div</span>&#123;<br>    <span class="hljs-attribute">width</span>:<span class="hljs-number">200px</span>;<br>    <span class="hljs-attribute">height</span>:<span class="hljs-number">200px</span>;<br>    <span class="hljs-comment">/* 调用动画 */</span><br>    <span class="hljs-attribute">animation-name</span>:move;<br>    <span class="hljs-comment">/* 持续时间 */</span><br>    <span class="hljs-attribute">animation-duration</span>:<span class="hljs-number">10s</span>;<br>&#125;<br></code></pre></td></tr></table></figure>

<h3 id="动画常见属性"><a href="#动画常见属性" class="headerlink" title="动画常见属性"></a>动画常见属性</h3><table>
<thead>
<tr>
<th>属性</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>@keyframes</td>
<td>规定动画</td>
</tr>
<tr>
<td>animation</td>
<td>所有动画属性的简写属性,除了animation-play-state属性。</td>
</tr>
<tr>
<td><strong>animation-name</strong></td>
<td>规定@keyframes动画的名称。( 必填)</td>
</tr>
<tr>
<td><strong>animation-duration</strong></td>
<td>规定动画完成一个周期所花费的秒或毫秒 ，默认是0。( 必填)</td>
</tr>
<tr>
<td>animation-timing-function</td>
<td>规定动画的速度曲线，默认是”ease” 。</td>
</tr>
<tr>
<td>animation-delay</td>
<td>规定动画何时开始，默认是0。</td>
</tr>
<tr>
<td>animation-iteration-count</td>
<td>规定动画被播放的次数，默认是1 ，还有infinite。</td>
</tr>
<tr>
<td>animation-direction</td>
<td>规定动画是否在下一周期逆向播放，默认是”normal “,alternate逆播放。</td>
</tr>
<tr>
<td>animation-play-state</td>
<td>规定动画是否正在运行或暂停。默认是”running ，还有”paused”。</td>
</tr>
<tr>
<td>animation-fill-mode</td>
<td>规定动画结束后状态，保持forwards回到起始backwards。</td>
</tr>
</tbody></table>
<p>简写形式</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs css"><span class="hljs-attribute">animation</span>: 动画名称  持续时间  运动曲线  何时开始  播放次数  是否反方向  动画起始或者结束的状态;<br></code></pre></td></tr></table></figure>

<ul>
<li>简写属性里面不包含animation-play- state</li>
<li>暂停动画: animation-play-state: puased; 经常和鼠标经过等其他配合使用</li>
<li>想要动画走回来, 而不是直接跳回来: animation-direction : alternate</li>
<li>盒子动画结束后,停在结束位置: animatiofnfill-mode : forwards</li>
</ul>
<h2 id="2D-x2F-3D-转换"><a href="#2D-x2F-3D-转换" class="headerlink" title="2D &#x2F; 3D 转换"></a>2D &#x2F; 3D 转换</h2><p><strong>转换transform</strong>是CSS3中具有颠覆性的特征之一，可以实现元素的位移、旋转、缩放等效果。</p>
<p><strong>常常与过渡结合，将转换写在hover中。实现鼠标经过慢动作展示移动、旋转、缩放。</strong></p>
<h3 id="二维坐标系"><a href="#二维坐标系" class="headerlink" title="二维坐标系"></a>二维坐标系</h3><h4 id="移动translate"><a href="#移动translate" class="headerlink" title="移动translate"></a>移动translate</h4><p>2D移动是2D转换里面的一种功能，可以改变元素在页面中的位置，类似定位。</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><code class="hljs css"><span class="hljs-selector-tag">div</span> &#123;<br>    <span class="hljs-attribute">width</span>:<span class="hljs-number">200px</span>;<br>    <span class="hljs-attribute">height</span>:<span class="hljs-number">200px</span>;<br>    <span class="hljs-attribute">background-color</span>:pink;<br>    <span class="hljs-comment">/* x就是x轴上移动位置y就是y辅上移动位置 中间用逗号分隔*/</span><br>    <span class="hljs-attribute">transform</span>: <span class="hljs-built_in">translate</span>(<span class="hljs-number">100px</span>, <span class="hljs-number">100px</span>);<br>     <span class="hljs-comment">/* 参数可以用%，按照盒子自身的宽度或者高度来对比*/</span><br>    // <span class="hljs-attribute">transform</span>: <span class="hljs-built_in">translateX</span>(<span class="hljs-number">50%</span>);<br>&#125;<br></code></pre></td></tr></table></figure>

<ul>
<li>定义2D转换中的移动,沿着X和Y轴移动元素</li>
<li>translate最大的优点 :不会影响到其他元素的位置</li>
<li>translate中的百分比单位是相对于自身元素的 translate:(50%,50%);</li>
<li>对行内标签没有效果</li>
</ul>
<h4 id="旋转rotate"><a href="#旋转rotate" class="headerlink" title="旋转rotate"></a>旋转rotate</h4><p>2D旋转指的是让元素在2维平面内顺时针旋转或者逆时针旋转。</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><code class="hljs css"><span class="hljs-selector-tag">img</span> &#123;<br>    <span class="hljs-attribute">width</span>:<span class="hljs-number">150px</span>;<br>    <span class="hljs-comment">/* 顺时针旋转45度 */</span><br>    <span class="hljs-attribute">transform</span>: <span class="hljs-built_in">rotate</span>(<span class="hljs-number">45deg</span>);<br>&#125;<br></code></pre></td></tr></table></figure>

<ul>
<li>rotate里面跟度数，单位是deg比如rotate(45deg)</li>
<li>角度为正时，顺时针，负时，为逆时针</li>
<li>默认旋转的中心点是元素的中心点</li>
</ul>
<p>改变旋转中心点transform-origin </p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs css"><span class="hljs-attribute">transform-origin</span>: x y;  //x,y默认是<span class="hljs-number">50%</span><br></code></pre></td></tr></table></figure>

<blockquote>
<p>还可以给xy设置像素或者方位名词 ( top bottom left right center )</p>
</blockquote>
<p>旋转<code>rotate</code>和过度<code>transition</code>结合可以实现旋转的过程展示</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><code class="hljs css"><span class="hljs-selector-tag">img</span> &#123;<br>    <span class="hljs-attribute">width</span>:<span class="hljs-number">150px</span>;<br>    <span class="hljs-comment">/* 顺时针旋转45度 */</span><br>    <span class="hljs-attribute">transition</span>:all <span class="hljs-number">0.3s</span>;<br>&#125;<br><span class="hljs-selector-tag">img</span><span class="hljs-selector-pseudo">:hover</span>&#123;<br>    <span class="hljs-attribute">transform</span>: <span class="hljs-built_in">rotate</span>(<span class="hljs-number">360deg</span>);<br>&#125;<br></code></pre></td></tr></table></figure>

<h4 id="缩放scale"><a href="#缩放scale" class="headerlink" title="缩放scale"></a>缩放scale</h4><p>只要给元素添加上了这个属性就能控制它放大还是缩小。</p>
<p>语法</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs css"><span class="hljs-attribute">transform</span>: <span class="hljs-built_in">scale</span>(x,y);  // x,y表示放大多少倍.只写一个参数的话第二个参数和第一个参数一样<br></code></pre></td></tr></table></figure>

<p>可以设置转换中心点缩放，默认以中心点缩放的,而且不影响其他盒子</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs css"><span class="hljs-attribute">transform-origin</span>: x y;  <br></code></pre></td></tr></table></figure>

<h4 id="2D转换综合写法"><a href="#2D转换综合写法" class="headerlink" title="2D转换综合写法"></a>2D转换综合写法</h4><ol>
<li>同时使用多个转换,其格式为: transform: translate() rotate()scale0) .等</li>
<li>其顺序会影转换的效果。( 先旋转会改变坐标轴方向)</li>
<li>当我们同时有位移和其他属性的时候,记得要将位移放到最前</li>
</ol>
<h3 id="三维坐标系"><a href="#三维坐标系" class="headerlink" title="三维坐标系"></a>三维坐标系</h3><p>三维坐标系其实就是指立体空间,立体空间是由3个轴共同组成的。</p>
<ul>
<li>x轴:水平向右  注意: x右边是正值，左边是负值</li>
<li>y轴:垂直向下  注意: y下面是正值，上面是负值</li>
<li>z轴:垂直屏幕  注意：往外面是正值，往里面是负值</li>
</ul>
<h4 id="3D位移translate3d-x-y-z"><a href="#3D位移translate3d-x-y-z" class="headerlink" title="3D位移translate3d(x,y,z)"></a>3D位移translate3d(x,y,z)</h4><p>3D移动在2D移动的基础上多加了一一个可以移动的方向，就是z轴方向。</p>
<ul>
<li>translform:translateX(100px) ：仅仅是在x轴上移动</li>
<li>translform:translateY(100px) ：仅仅是在Y轴上移动</li>
<li>translform:translateZ(100px) ：仅仅是在Z轴上移动(注意: translateZ-般用px单位 )</li>
<li>transform:translate3d(x,y,z) ：其中x、y、z分别指要移动的轴的方向的距离，xyz不能省略，没有就写0</li>
</ul>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs css"><span class="hljs-attribute">transform</span>: <span class="hljs-built_in">translate3d</span>(<span class="hljs-number">100px</span>, <span class="hljs-number">100px</span>, <span class="hljs-number">100px</span>);<br></code></pre></td></tr></table></figure>

<h4 id="透视：perspective"><a href="#透视：perspective" class="headerlink" title="透视：perspective"></a>透视：perspective</h4><p>在2D平面产生近大远小视觉立体，但是只是效果二维的。如果想要在网页产生3D效果需要透视(理解成3D物体投影在2D平面内)。</p>
<p>透视写在被观察元系的父盒子上面的</p>
<ul>
<li>d：就是视距,视距就是一个距离人的眼睛到屏幕的距离。</li>
<li>z：就是z轴,物体距离屏幕的距离, z轴越大(正值)我们看到的物体就越大。</li>
</ul>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><code class="hljs css"><span class="hljs-selector-tag">body</span>&#123;<br>    <span class="hljs-attribute">perspective</span>:<span class="hljs-number">500px</span>;  // 透视d越小，眼睛距离屏幕越近，看到的物体越大<br>&#125;<br></code></pre></td></tr></table></figure>

<p>在父盒子上设置了透视， 此时再在子上设置translform:translateZ就可以控制盒子的大小，值越大越靠近眼睛越大。</p>
<h4 id="3D旋转rotate3d-x-y-z"><a href="#3D旋转rotate3d-x-y-z" class="headerlink" title="3D旋转rotate3d(x,y,z)"></a>3D旋转rotate3d(x,y,z)</h4><p>3D旋转指可以让元素在三维平面内沿着x轴, y轴, z轴或者自定义轴进行旋转。</p>
<ul>
<li>transform:rotateX(45deg) ：沿着x轴正方向旋转45度</li>
<li>transform:rotateY(45deg) ：沿着y轴正方向旋转45deg</li>
<li>transform:rotateZ(45deg) ：沿着Z轴正方向旋转45deg</li>
<li>transform:rotate3d(x,y,z,deg) ： 沿着自定义轴旋转deg为角度(了解即可)</li>
</ul>
<blockquote>
<p>根据左手法则判断度数为正时的旋转方向，即左手大拇指指向轴的正方形，其他手指自然弯曲的方向。</p>
</blockquote>
<h4 id="3D呈现transfrom-style"><a href="#3D呈现transfrom-style" class="headerlink" title="3D呈现transfrom-style"></a>3D呈现transfrom-style</h4><ul>
<li>控制子元素是否开启三维立体环境。</li>
<li>transform-style: flat子元素不开启3d立体空间默认的</li>
<li>transform-style: preserve- 3d; 子元素开启立体空间</li>
<li>代码写给父级，但是影响的是子盒子</li>
</ul>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br></pre></td><td class="code"><pre><code class="hljs css">&lt;style&gt;<br>    <span class="hljs-selector-tag">body</span>&#123;<br>        // 加透视<br>        <span class="hljs-attribute">perspective</span>:<span class="hljs-number">500px</span>;<br>    &#125;<br>    <span class="hljs-selector-class">.box</span>&#123;<br>        <span class="hljs-attribute">position</span>: relative;<br>        <span class="hljs-attribute">width</span>: <span class="hljs-number">200px</span>;<br>        <span class="hljs-attribute">height</span>: <span class="hljs-number">200px</span>; <br>        <span class="hljs-attribute">margin</span>: <span class="hljs-number">100px</span> auto;<br>        // 看到属性改变的过程(hover的过程)<br>        <span class="hljs-attribute">transition</span>: all <span class="hljs-number">2s</span>;<br>        <span class="hljs-comment">/*让子元素保持3d立体空间环境*/</span><br>        <span class="hljs-attribute">transform-style</span>: preserve-<span class="hljs-number">3</span>d;<br>    &#125;<br><br>    <span class="hljs-selector-class">.box</span><span class="hljs-selector-pseudo">:hover</span>&#123;<br>        <span class="hljs-attribute">transform</span>:<span class="hljs-built_in">rotateY</span>(<span class="hljs-number">60deg</span>);<br>    &#125;<br>		<br>    <span class="hljs-selector-class">.box</span> <span class="hljs-selector-tag">div</span>&#123;<br>		<span class="hljs-attribute">position</span>:absolute;<br>        <span class="hljs-attribute">top</span>: <span class="hljs-number">0</span>;<br>        <span class="hljs-attribute">left</span>: <span class="hljs-number">0</span>;<br>        <span class="hljs-attribute">width</span>: <span class="hljs-number">100%</span>;<br>        <span class="hljs-attribute">height</span>: <span class="hljs-number">100%</span>;<br>		<span class="hljs-attribute">background-color</span>:pink;<br>    &#125;<br><br>	<span class="hljs-selector-class">.box</span> <span class="hljs-selector-tag">div</span><span class="hljs-selector-pseudo">:last-child</span>&#123;<br>		<span class="hljs-attribute">background-color</span>:purple;<br>        <span class="hljs-attribute">transform</span>:<span class="hljs-built_in">rotateX</span>(<span class="hljs-number">60deg</span>); <br>    &#125;<br>&lt;/style&gt;<br><br>&lt;<span class="hljs-selector-tag">body</span>&gt;<br>	&lt;<span class="hljs-selector-tag">div</span> class=&quot;box&gt;<br>		&lt;<span class="hljs-selector-tag">div</span>&gt;&lt;/<span class="hljs-selector-tag">div</span>&gt;<br>		&lt;<span class="hljs-selector-tag">div</span>&gt;&lt;/<span class="hljs-selector-tag">div</span>&gt;	<br>	&lt;/<span class="hljs-selector-tag">div</span>&gt;<br>&lt;/<span class="hljs-selector-tag">body</span>&gt;<br></code></pre></td></tr></table></figure>


                
              </div>
            
            <hr/>
            <div>
              <div class="post-metas my-3">
  
    <div class="post-meta mr-3 d-flex align-items-center">
      <i class="iconfont icon-category"></i>
      

<span class="category-chains">
  
  
    
      <span class="category-chain">
        
  <a href="/blog/categories/%E5%89%8D%E7%AB%AF%E6%8A%80%E6%9C%AF%E6%A0%88/" class="category-chain-item">前端技术栈</a>
  
  
    <span>></span>
    
  <a href="/blog/categories/%E5%89%8D%E7%AB%AF%E6%8A%80%E6%9C%AF%E6%A0%88/css/" class="category-chain-item">css</a>
  
  

  

      </span>
    
  
</span>

    </div>
  
  
    <div class="post-meta">
      <i class="iconfont icon-tags"></i>
      
        <a href="/blog/tags/css/">#css</a>
      
    </div>
  
</div>


              
  

  <div class="license-box my-3">
    <div class="license-title">
      <div>CSS3特性</div>
      <div>https://airfe.gitee.io/blog/2023/04/19/CSS3特性/</div>
    </div>
    <div class="license-meta">
      
        <div class="license-meta-item">
          <div>作者</div>
          <div>Airfe</div>
        </div>
      
      
        <div class="license-meta-item license-meta-date">
          <div>发布于</div>
          <div>2023年4月19日</div>
        </div>
      
      
      
        <div class="license-meta-item">
          <div>许可协议</div>
          <div>
            
              
              
                <a target="_blank" href="https://creativecommons.org/licenses/by/4.0/">
                  <span class="hint--top hint--rounded" aria-label="BY - 署名">
                    <i class="iconfont icon-by"></i>
                  </span>
                </a>
              
            
          </div>
        </div>
      
    </div>
    <div class="license-icon iconfont"></div>
  </div>



              
                <div class="post-prevnext my-3">
                  <article class="post-prev col-6">
                    
                    
                      <a href="/blog/2023/04/27/%E8%BF%AD%E4%BB%A3%E5%99%A8%E4%B8%8E%E7%94%9F%E6%88%90%E5%99%A8/" title="迭代器与生成器">
                        <i class="iconfont icon-arrowleft"></i>
                        <span class="hidden-mobile">迭代器与生成器</span>
                        <span class="visible-mobile">上一篇</span>
                      </a>
                    
                  </article>
                  <article class="post-next col-6">
                    
                    
                      <a href="/blog/2023/04/17/BFC%E5%92%8CIFC%E6%9C%BA%E5%88%B6/" title="BFC和IFC机制">
                        <span class="hidden-mobile">BFC和IFC机制</span>
                        <span class="visible-mobile">下一篇</span>
                        <i class="iconfont icon-arrowright"></i>
                      </a>
                    
                  </article>
                </div>
              
            </div>

            
  
  
    <article id="comments" lazyload>
      
  <div id="valine"></div>
  <script type="text/javascript">
    Fluid.utils.loadComments('#valine', function() {
      Fluid.utils.createScript('https://lib.baomitu.com/valine/1.5.1/Valine.min.js', function() {
        var options = Object.assign(
          {"appId":"RW68dMkEpeIOJJiBr1lPkhOS-gzGzoHsz","appKey":"P5fzMTGSJIoTaGvmgzsUHeNZ","path":"window.location.pathname","placeholder":"发表你的看法吧~","avatar":"retro","meta":["nick","mail","link"],"requiredFields":[],"pageSize":10,"lang":"zh-CN","highlight":false,"recordIP":false,"serverURLs":"","emojiCDN":null,"emojiMaps":null,"enableQQ":false,"appid":"RW68dMkEpeIOJJiBr1lPkhOS-gzGzoHsz","appkey":"P5fzMTGSJIoTaGvmgzsUHeNZ","server_url":"https://rw68dmke.lc-cn-n1-shared.com"},
          {
            el: "#valine",
            path: window.location.pathname
          }
        )
        new Valine(options);
        Fluid.utils.waitElementVisible('#valine .vcontent', () => {
          var imgSelector = '#valine .vcontent img:not(.vemoji)';
          Fluid.plugins.imageCaption(imgSelector);
          Fluid.plugins.fancyBox(imgSelector);
        })
      });
    });
  </script>
  <noscript>Please enable JavaScript to view the comments</noscript>


    </article>
  


          </article>
        </div>
      </div>
    </div>

    <div class="side-col d-none d-lg-block col-lg-2">
      
  <aside class="sidebar" style="margin-left: -1rem">
    <div id="toc">
  <p class="toc-header">
    <i class="iconfont icon-list"></i>
    <span>目录</span>
  </p>
  <div class="toc-body" id="toc-body"></div>
</div>



  </aside>


    </div>
  </div>
</div>





  



  



  



  



  







    

    
      <a id="scroll-top-button" aria-label="TOP" href="#" role="button">
        <i class="iconfont icon-arrowup" aria-hidden="true"></i>
      </a>
    

    
      <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
     aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">搜索</h4>
        <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input type="text" id="local-search-input" class="form-control validate">
          <label data-error="x" data-success="v" for="local-search-input">关键词</label>
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>

    

    
  </main>

  <footer>
    <div class="footer-inner">
  
    <div class="footer-content">
        <a href="https://hexo.io" target="_blank" rel="nofollow noopener"><span>Hexo</span></a> <i class="iconfont icon-love"></i> <a href="https://github.com/fluid-dev/hexo-theme-fluid" target="_blank" rel="nofollow noopener"><span>Fluid</span></a> <div style="font-size: 0.85rem"> <span id="timeDate">载入天数</span> <span id="times">载入时分秒</span> <script src="js/duration.js"></script> </div> 
    </div>
  
  
    <div class="statistics">
  
  

  
    
      <span id="leancloud-site-pv-container" style="display: none">
        总访问量 
        <span id="leancloud-site-pv"></span>
         次
      </span>
    
    
      <span id="leancloud-site-uv-container" style="display: none">
        总访客数 
        <span id="leancloud-site-uv"></span>
         人
      </span>
    
    

  
</div>

  
  
    <!-- 备案信息 ICP for China -->
    <div class="beian">
  <span>
    <a href="http://beian.miit.gov.cn/" target="_blank" rel="nofollow noopener">
      蜀ICP备2023008943号
    </a>
  </span>
  
    
      <span>
        <a
          href="http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=https://beian.miit.gov.cn/"
          rel="nofollow noopener"
          class="beian-police"
          target="_blank"
        >
          
            <span style="visibility: hidden; width: 0">|</span>
            <img src="" srcset="/blog/img/loading.gif" lazyload data-original="/blog/img/police_beian.png" alt="police-icon"/>
          
          <span>京公网安备12345678号</span>
        </a>
      </span>
    
  
</div>

  
  
</div>

  </footer>

  <!-- Scripts -->
  
  <script  src="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.js" ></script>
  <link  rel="stylesheet" href="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.css" />

  <script>
    NProgress.configure({"showSpinner":false,"trickleSpeed":100})
    NProgress.start()
    window.addEventListener('load', function() {
      NProgress.done();
    })
  </script>


<script  src="https://lib.baomitu.com/jquery/3.6.0/jquery.min.js" ></script>
<script  src="https://lib.baomitu.com/twitter-bootstrap/4.6.1/js/bootstrap.min.js" ></script>
<script  src="/blog/js/events.js" ></script>
<script  src="/blog/js/plugins.js" ></script>


  <script  src="https://lib.baomitu.com/typed.js/2.0.12/typed.min.js" ></script>
  <script>
    (function (window, document) {
      var typing = Fluid.plugins.typing;
      var subtitle = document.getElementById('subtitle');
      if (!subtitle || !typing) {
        return;
      }
      var text = subtitle.getAttribute('data-typed-text');
      
        typing(text);
      
    })(window, document);
  </script>




  
    <script  src="/blog/js/img-lazyload.js" ></script>
  




  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/tocbot/4.18.2/tocbot.min.js', function() {
    var toc = jQuery('#toc');
    if (toc.length === 0 || !window.tocbot) { return; }
    var boardCtn = jQuery('#board-ctn');
    var boardTop = boardCtn.offset().top;

    window.tocbot.init(Object.assign({
      tocSelector     : '#toc-body',
      contentSelector : '.markdown-body',
      linkClass       : 'tocbot-link',
      activeLinkClass : 'tocbot-active-link',
      listClass       : 'tocbot-list',
      isCollapsedClass: 'tocbot-is-collapsed',
      collapsibleClass: 'tocbot-is-collapsible',
      scrollSmooth    : true,
      includeTitleTags: true,
      headingsOffset  : -boardTop,
    }, CONFIG.toc));
    if (toc.find('.toc-list-item').length > 0) {
      toc.css('visibility', 'visible');
    }

    Fluid.events.registerRefreshCallback(function() {
      if ('tocbot' in window) {
        tocbot.refresh();
        var toc = jQuery('#toc');
        if (toc.length === 0 || !tocbot) {
          return;
        }
        if (toc.find('.toc-list-item').length > 0) {
          toc.css('visibility', 'visible');
        }
      }
    });
  });
</script>


  <script src=https://lib.baomitu.com/clipboard.js/2.0.11/clipboard.min.js></script>

  <script>Fluid.plugins.codeWidget();</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/anchor-js/4.3.1/anchor.min.js', function() {
    window.anchors.options = {
      placement: CONFIG.anchorjs.placement,
      visible  : CONFIG.anchorjs.visible
    };
    if (CONFIG.anchorjs.icon) {
      window.anchors.options.icon = CONFIG.anchorjs.icon;
    }
    var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
    var res = [];
    for (var item of el) {
      res.push('.markdown-body > ' + item.trim());
    }
    if (CONFIG.anchorjs.placement === 'left') {
      window.anchors.options.class = 'anchorjs-link-left';
    }
    window.anchors.add(res.join(', '));

    Fluid.events.registerRefreshCallback(function() {
      if ('anchors' in window) {
        anchors.removeAll();
        var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
        var res = [];
        for (var item of el) {
          res.push('.markdown-body > ' + item.trim());
        }
        if (CONFIG.anchorjs.placement === 'left') {
          anchors.options.class = 'anchorjs-link-left';
        }
        anchors.add(res.join(', '));
      }
    });
  });
</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.js', function() {
    Fluid.plugins.fancyBox();
  });
</script>


  <script>Fluid.plugins.imageCaption();</script>

  <script defer src="/blog/js/leancloud.js" ></script>

  <script  src="/blog/js/local-search.js" ></script>





<!-- 主题的启动项，将它保持在最底部 -->
<!-- the boot of the theme, keep it at the bottom -->
<script  src="/blog/js/boot.js" ></script>


  

  <noscript>
    <div class="noscript-warning">博客在允许 JavaScript 运行的环境下浏览效果更佳</div>
  </noscript>

        <style>
            [bg-lazy] {
                background-image: none !important;
                background-color: #eee !important;
            }
        </style>
        <script>
            window.imageLazyLoadSetting = {
                isSPA: false,
                preloadRatio: 1,
                processImages: null,
            };
        </script><script>window.addEventListener("load",function(){var t=/\.(gif|jpg|jpeg|tiff|png)$/i,r=/^data:image\/[a-z]+;base64,/;Array.prototype.slice.call(document.querySelectorAll("img[data-original]")).forEach(function(a){var e=a.parentNode;"A"===e.tagName&&(e.href.match(t)||e.href.match(r))&&(e.href=a.dataset.original)})});</script><script>!function(r){r.imageLazyLoadSetting.processImages=t;var e=r.imageLazyLoadSetting.isSPA,n=r.imageLazyLoadSetting.preloadRatio||1,c=a();function a(){var t=Array.prototype.slice.call(document.querySelectorAll("img[data-original]")),e=Array.prototype.slice.call(document.querySelectorAll("[bg-lazy]"));return t.concat(e)}function t(){e&&(c=a());for(var t,o=0;o<c.length;o++)0<=(t=(t=c[o]).getBoundingClientRect()).bottom&&0<=t.left&&t.top<=(r.innerHeight*n||document.documentElement.clientHeight*n)&&function(){var t,e,n,a,i=c[o];e=function(){c=c.filter(function(t){return i!==t}),r.imageLazyLoadSetting.onImageLoaded&&r.imageLazyLoadSetting.onImageLoaded(i)},(t=i).hasAttribute("bg-lazy")?(t.removeAttribute("bg-lazy"),e&&e()):(n=new Image,a=t.getAttribute("data-original"),n.onload=function(){t.src=a,t.removeAttribute("data-original"),e&&e()},t.src!==a&&(n.src=a))}()}function i(){clearTimeout(t.tId),t.tId=setTimeout(t,500)}t(),document.addEventListener("scroll",i),r.addEventListener("resize",i),r.addEventListener("orientationchange",i)}(this);</script></body>
</html>
